package com.kczd.jinlan.view.mine.fragment;

import android.graphics.Bitmap;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.kczd.jinlan.R;
import com.kczd.jinlan.utils.Config;
import com.kczd.jinlan.view.mine.EditDataActivity;
import com.kczd.jinlan.view.mine.EvaluateActivity;
import com.kczd.jinlan.view.mine.LocationActivity;
import com.kczd.jinlan.view.mine.SecurityActivity;
import com.kczd.jinlan.view.mine.SetupActivity;
import com.kczd.jinlan.view.mine.WalletActivity;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;

/**
 * yang_g
 * 我的模块
 * Created by Administrator on 2017/5/15.
 */

public class MyFragment extends BaseFragment implements View.OnClickListener {
    private View view;
    private TextView text_personal_data;//个人资料
    private LinearLayout linear_security;//安全中心
    private LinearLayout linear_evaluate;//我的评价
    private LinearLayout linear_location;//收货地址
    private LinearLayout linear_Set_up;//设置

    private TextView text_wallet;//钱包
    private ImageView image_view_my;//头像
    private TextView tv_name,tv_sign;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.my_fragment, null);
        init();
//        setUserInfo();
        return view;
    }

    public void setUserInfo() {
        String uImage =Config.user.getHead_pic();
        // 显示图片的配置
        DisplayImageOptions options = new DisplayImageOptions.Builder().showImageOnLoading(R.mipmap.img_loading)
                .showImageOnFail(R.mipmap.img_fail).cacheInMemory(true).cacheOnDisk(true)
                .bitmapConfig(Bitmap.Config.RGB_565).build();
        ImageLoader.getInstance().displayImage(uImage, image_view_my, options);
        tv_name.setText(Config.user.getNickname());
        tv_sign.setText(Config.user.getSign());
    }
    private void init() {
        text_personal_data = (TextView) view.findViewById(R.id.text_personal_data);
        text_personal_data.setOnClickListener(this);
        linear_security = (LinearLayout) view.findViewById(R.id.linear_security);
        linear_security.setOnClickListener(this);
        linear_Set_up = (LinearLayout) view.findViewById(R.id.linear_Set_up);
        linear_Set_up.setOnClickListener(this);
        linear_location = (LinearLayout) view.findViewById(R.id.linear_location);
        linear_location.setOnClickListener(this);
        text_wallet = (TextView) view.findViewById(R.id.text_wallet);
        text_wallet.setOnClickListener(this);
        image_view_my = (ImageView) view.findViewById(R.id.image_view_my);
        image_view_my.setOnClickListener(this);
        linear_evaluate = (LinearLayout) view.findViewById(R.id.linear_evaluate);
        linear_evaluate.setOnClickListener(this);
        tv_name= (TextView) view.findViewById(R.id.tv_name);
        tv_sign= (TextView) view.findViewById(R.id.tv_sign);
    }


    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.text_personal_data://个人资料
                gotoActivity(getContext(), EditDataActivity.class);
                break;
            case R.id.linear_security://安全中心
                gotoActivity(getContext(), SecurityActivity.class);
                break;
            case R.id.linear_Set_up://设置
                gotoActivity(getContext(), SetupActivity.class);
                break;
            case R.id.text_wallet://钱包
                gotoActivity(getContext(), WalletActivity.class);
                break;
            case R.id.image_view_my://头像

                break;
            case R.id.linear_evaluate://我的评价
                gotoActivity(getContext(), EvaluateActivity.class);
                break;
            case R.id.linear_location://收货地址
                gotoActivity(getContext(), LocationActivity.class);
                break;
        }
    }
}
